#include <bits/stdc++.h>
// 2025/02/01
// tag: 
// Author: Zhang Muen
using namespace std;

int n, opt, MIN, MAX, MOD;
int64_t diff[80005], nums[80005];

void add(int l, int r, int64_t val){
    diff[l] += val;
    diff[r + 1] -= val;
}

int64_t ask(int l, int r){
    int64_t s = 0, cnt = 0;
    for (int i = 0; i < l; i++) 
        s += diff[i];
    for (int i = l; i <= r; i++){
        s += diff[i];
        if (MIN <= s * i % MOD && s * i % MOD <= MAX)
            cnt++;
    }
    return cnt;
}

signed main()
{
    cin >> n >> opt >> MOD >> MIN >> MAX;
    for (int i = 1; i <= opt; i++) {
        char type;
        cin >> type;
        int l, r, val;
        cin >> l >> r;
        if (type == 'A'){
            cin >> val;
            add(l, r, val);
        }
        else{
            cout << ask(l, r) << endl;
        }
    }
    int q;
    int64_t s = 0;
    for (int i = 1; i <= n; i++){
        s += diff[i];
        nums[i] = nums[i - 1] + bool(s * i % MOD <= MAX && s * i % MOD >= MIN);
    }
    cin >> q;
    for (int i = 1; i <= q; i++) {
        int l, r;
        cin >> l >> r;
        cout << nums[r] - nums[l - 1] << endl;
    }

    return 0;
}